Problem Note 67972: An %IF statement in open code can insert additional semicolons in the code after the code is resolved
An %IF statement in open code inserts additional semicolons into submitted code after resolution when the following conditions are met:
- An %ELSE branch is specified with the %IF test.
- The %IF test resolves to FALSE, making the code take the %ELSE branch.
The behavior can be illustrated after you submit the following sample macro:
%macro test(var);
data _null_;
put "&VAR";
run;
%mend;
When the macro is called in open code and its input parameter (VAR) contains an %IF test that resolves to TRUE, the correct results are generated, as shown in the SAS® log here:
%test(%IF 1 %THEN %DO; 123 %END;%ELSE %DO; 456 %END;)
MLOGIC(TEST): Beginning execution.
MLOGIC(TEST): Parameter VAR has value 123
MPRINT(TEST): data _null_;
SYMBOLGEN: Macro variable VAR resolves to 123
MPRINT(TEST): put "123";
MPRINT(TEST): run;
123
NOTE: DATA statement used (Total process time):
However, if you submit the macro with an %IF test that resolves to FALSE, additional semicolons are generated in the code:
%test(%IF 0 %THEN %DO; 123 %END;%ELSE %DO; 456 %END;)
MLOGIC(TEST): Beginning execution.
MLOGIC(TEST): Parameter VAR has value ; 456;
MPRINT(TEST): data _null_;
SYMBOLGEN: Macro variable VAR resolves to ; 456;
MPRINT(TEST): put "; 456;";
MPRINT(TEST): run;
; 456;
NOTE: DATA statement used (Total process time):
A workaround is to modify the logic of the code so that the %ELSE branch is not used. A further code modification is to not use an %IF statement in open code.
Click the Hot Fix tab in this note to access the hot fix for this issue.
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
z/OS 64-bit | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft® Windows® for x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows 8 Enterprise x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows 8 Pro x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows 8.1 Enterprise 32-bit | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows 8.1 Enterprise x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows 8.1 Pro 32-bit | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows 8.1 Pro x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows 10 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows Server 2008 R2 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows Server 2008 for x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows Server 2012 Datacenter | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows Server 2012 R2 Datacenter | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows Server 2012 R2 Std | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Microsoft Windows Server 2012 Std | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Windows 7 Enterprise x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Windows 7 Professional x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
64-bit Enabled AIX | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
64-bit Enabled Solaris | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
HP-UX IPF | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Linux for x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
Solaris for x64 | 9.4 | 9.4_M8 | 9.4 TS1M0 | 9.4 TS1M8 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Type: | Problem Note |
Priority: | medium |
Date Modified: | 2021-06-07 14:45:23 |
Date Created: | 2021-05-28 01:25:59 |